<?php

/**
 * Receipt form base class.
 *
 * @package    form
 * @subpackage receipt
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseReceiptForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'year_id'      => new sfWidgetFormDoctrineSelect(array('model' => 'Year', 'add_empty' => false)),
      'vehicle_id'   => new sfWidgetFormDoctrineSelect(array('model' => 'Vehicle', 'add_empty' => false)),
      'amount_paid'  => new sfWidgetFormInput(),
      'o_r'          => new sfWidgetFormInput(),
      'date'         => new sfWidgetFormDate(),
      'gov_permit'   => new sfWidgetFormInput(),
      'collector_id' => new sfWidgetFormDoctrineSelect(array('model' => 'Collector', 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorDoctrineChoice(array('model' => 'Receipt', 'column' => 'id', 'required' => false)),
      'year_id'      => new sfValidatorDoctrineChoice(array('model' => 'Year')),
      'vehicle_id'   => new sfValidatorDoctrineChoice(array('model' => 'Vehicle')),
      'amount_paid'  => new sfValidatorNumber(array('required' => false)),
      'o_r'          => new sfValidatorString(array('max_length' => 10)),
      'date'         => new sfValidatorDate(array('required' => false)),
      'gov_permit'   => new sfValidatorNumber(array('required' => false)),
      'collector_id' => new sfValidatorDoctrineChoice(array('model' => 'Collector')),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Receipt', 'column' => array('o_r')))
    );

    $this->widgetSchema->setNameFormat('receipt[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Receipt';
  }

}